package com.satan.vote.controller;

import com.satan.vote.dto.WxUserInfoDTO;
import com.satan.vote.entity.WxUserInfo;
import com.satan.vote.service.WxUserInfoService;
import com.satan.vote.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName WxUserController
 * @Description TODO
 * @date 2023/8/10 13:39
 * @Version 1.0
 */
@RestController
@RequestMapping("user")
public class WxUserController {
    @Autowired
    private WxUserInfoService wxUserInfoService;


    //登录
    @RequestMapping("/wxLogin")
    public ResultVO wxLogin(@RequestBody WxUserInfoDTO wxUserInfoDTO){
        return wxUserInfoService.wxLogin(wxUserInfoDTO);
    }
    //获取用户信息
    @GetMapping("/getUserInfo")
    public ResultVO getUserInfo(@RequestHeader String token){
        return wxUserInfoService.getUserInfo(token);

    }
    /**
     * 更新用户昵称
     * @param wxUserInfo
     * @param token
     * @return
     */
    @RequestMapping("/updateNickName")
    public ResultVO updateNickName(@RequestBody WxUserInfo wxUserInfo, @RequestHeader String
            token){
        return  wxUserInfoService.updateNickName(wxUserInfo,token);
    }

    @RequestMapping("/uploadUserImage")
    public ResultVO uploadUserImage(MultipartFile userImage,
                                              @RequestHeader String token)throws Exception{
        return wxUserInfoService.uploadUserImage(userImage,token);
    }


}
